// middlewares/upload.js
const { koaBody } = require("koa-body");
const path = require("path");

const uploadMiddleware = koaBody({
    multipart: true, // 允许解析表单为文件的数据
    formidable: {
        uploadDir: path.join(__dirname, "../../tmp"), // 设置上传目录
        keepExtensions: true, // 保持文件扩展名
        maxFileSize: 10 * 1024 * 1024, // 设置最大文件大小为10MB
    },
});

module.exports = uploadMiddleware;
